<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
  String path = request.getContextPath();
%>
<html>
<jsp:include page="../common/init.jsp"></jsp:include>
	<head>
		<title>用户组列表页面</title>
        <link rel="stylesheet" href="<%=path%>/css/fixedTable.css" type="text/css" />
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/javaScript/jquery.js"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/javaScript/jquery.fixedheadertable.min.js"></script>
		<script type="text/javascript">
		 $(document).ready(function(){
			    $('#listTable').fixedHeaderTable({altClass: 'odd', themeClass: 'fancyTable', autoShow: false });
			    $('#listTable').fixedHeaderTable('show');
         }); 
	</script>
  </head>
<script type="text/javascript">
var yhzbhs = "";//用户组编号
//验证用户组checkBoxx是否选中
function checkSCount() 
{
	var intSCount=0;
	if (document.forms[0].yhzbh!=null)
	{	
		if(document.forms[0].yhzbh.length>1) 
		{
		
			for(i=0;i<document.forms[0].yhzbh.length;i++) 
			{
				if(document.forms[0].yhzbh[i].checked)
				{
					intSCount=intSCount+1;
					yhzbhs +=document.forms[0].yhzbh[i].value+",";
				}
			}
			
		} 
		else 
		{
			if(document.forms[0].yhzbh.checked)  
			{
				intSCount=1;
				yhzbhs +=document.forms[0].yhzbh.value;
			}
		}
	}
	return intSCount;
}
//数据查询;
function doSear(action)
{
	if(isSpecial(document.getElementById("yhzm").value))
	{
		alert("用户组名包含非法字符,请重新输入!");
		document.getElementById("yhzm").focus();
		return false;
	}
	else
	{
		doSearch(action);
	}
}
//用户组添加
function doAdd()
{
	popPage("createYhzForm.do",400,450);
}

//用户组删除
function doDelete(yhzbh)
{
	var  action="removeYhz.do";
	if(yhzbh!="")
	{
		yhzbhs="";
		yhzbhs=yhzbh;
	}
	else if(checkSCount()<1)
	{
		alert("请选中要删除的记录!");
		return false;
	}
	document.forms[0].yhzbhs.value=yhzbhs;
	var temp = "";
	var delFlag = 0;
	for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
	{
	     temp=parent.bottomFrame.rightForm.yhbhs.options[j].value;
	     if(temp.endWith("/0"))
	     {
		     temp=","+temp.substring(0,temp.indexOf("/"))+",";
		     if((","+yhzbhs+",").indexOf(temp)>-1)
		     {
		         delFlag=1;
		         break;
		     }
	     }
	}
	if(delFlag==1)
	{
	     alert("待授权用户/用户组区存在要删除的用户组，\n不能进行删除操作！");
	     return false;
	}
	if(confirm("确定要删除数据吗?"))
	{
		document.forms[0].action=action;
		document.forms[0].submit();
	}	
	else
	{
		return false;
	}

}
function doEdit(yhzbh)
{
	var temp = "";
	var editFlag = 0;
	for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
	{
	     temp=parent.bottomFrame.rightForm.yhbhs.options[j].value;
	     if(temp.endWith("/0"))
	     {
		     temp=","+temp.substring(0,temp.indexOf("/"))+",";
		     if((","+yhzbh+",").indexOf(temp)>-1)
		     {
		         editFlag=1;
		         break;
		     }
	     }
	}
	if(editFlag==1)
	{
	     alert("待授权用户/用户组区存在要修改的用户组，\n不能进行修改操作！");
	     return false;
	}
	else
	{
		popPage('reworkYhzForm.do?yhzbhs='+yhzbh,300,450);
	}
}
//生成功能按钮	
mpmenu1=new mMenu('','doAdd()','script','<%=path %>/images/img_ht_wz_37.gif','62','24','0','100','2');
mpmenu3=new mMenu('','doDelete(\"\")','script','<%=path %>/images/img_ht_wz_41.gif','62','24','0','20','0');
mpmenu4=new mMenu('','doSear(\"yhzList.do\")','script','<%=path %>/images/img_ht_wz_46.gif','62','24','0','300','0');
//用户授权
function doRight(action)
{
	action+="&tempid=" + Math.random();
	win = window.showModalDialog(action,null,'dialogHeight=650px;dialogWidth=750px;status=no;scroll=no;help=no');
	data=win;
	if(data!=null&&data[0]=='noRight'){	
		popPage("rightAction.do?yhzbh="+data[1],650,750);	
	 }
}
function addrole()         
{         
	var estlag = 0 ;
	var outValue="";
	var num = 0;
	if (document.forms[0].yhzbh!=null)
	{
		if(document.forms[0].yhzbh.length>1) 
		{
			for(i=0;i<document.forms[0].yhzbh.length;i++)  
			{
				estlag = 0 ;
				if(document.forms[0].yhzbh[i].checked)         
				{         
					outValue=document.forms[0].yhzms[i].value+"(用户组)";
					estlag = 1;
					num ++;					         
					//break;         
				} 
				if(estlag==1)
				{
					
					for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
					{         
						if(parent.bottomFrame.rightForm.yhbhs.options[j].text==outValue)         
						{         
							estlag = 0;         
							break;         
						}
					}         
					if(estlag == 1)
					{
					rolecnt = parent.bottomFrame.rightForm.yhbhs.length;         
					rolecnt++;         
					parent.bottomFrame.rightForm.yhbhs.length = rolecnt ;        
					parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].text = outValue;         
					parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].value = document.forms[0].yhzbh[i].value;//+"/"+"0";
					}         
				}
			}
		}
		else
		{
			estlag = 0 ;
			if(document.forms[0].yhzbh.checked)
			{
				outValue=document.forms[0].yhzms.value+"(用户组)";
				estlag = 1;	
				num ++;	
			}
			if(estlag==1)
			{
				for(j=0;j<parent.bottomFrame.rightForm.yhbhs.length;j++)
				{         
					if(parent.bottomFrame.rightForm.yhbhs.options[j].text==outValue)         
					{         
						estlag = 0;         
						break;         
					}
				}         
				if(estlag == 1)
				{
				rolecnt = parent.bottomFrame.rightForm.yhbhs.length;         
				rolecnt++;         
				parent.bottomFrame.rightForm.yhbhs.length = rolecnt ;        
				parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].text = outValue;         
				parent.bottomFrame.rightForm.yhbhs.options[rolecnt-1].value = document.forms[0].yhzbh.value;//+"/"+"0";
				}         
			}
		}
	}
    if(num==0)
	{
		alert("请首先选中要授权的用户组！");
		return;
	}                 
} 
</script>
<body>
<s:form name="yhz" action="" method="get">
<table cellspacing="0" cellpadding="0" class="main_tab1">
<tr>
<td colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="<%=path %>/images/img_biaoqian_5.gif">
  <tr>
    <td width="10%">
		<table border="0" cellspacing="0" cellpadding="0" class="main_tab1">
      	<tr>
        	<td width="5"><img src="<%=path %>/images/img_biaoqian_u_1.gif"></td>
        	<td align="center" nowrap background="<%=path %>/images/img_biaoqian_u_2.gif">
        	&nbsp;&nbsp;&nbsp;&nbsp;<a href="listDlyh.do">用户管理</a>&nbsp;&nbsp;&nbsp;&nbsp;
        	</td>
        	<td width="5"><img src="<%=path %>/images/img_biaoqian_u_4.gif"></td>
      	</tr>
    	</table>
		</td>
    <td width="10%">
	<table border="0" cellspacing="0" cellpadding="0" class="main_tab1">
      <tr>
        <td width="5"><img src="<%=path %>/images/img_biaoqian_i_1.gif"></td>
        	<td align="center" nowrap background="<%=path %>/images/img_biaoqian_i_2.gif">
        			&nbsp;&nbsp;&nbsp;<strong>用户组管理</strong>&nbsp;&nbsp;&nbsp;
        	</td>
        	<td width="5"><img src="<%=path %>/images/img_biaoqian_i_3.gif"></td>
     		</tr>
    	</table>
		</td>
    <td width="80%">&nbsp;</td>
  </tr>
</TABLE>
</td>
</tr>
    <tr>
        <td class=""><img src="<%=path %>/images/img_ht_wz_28.gif" alt="left" /></td>
        <td class="main_tab1_td2">
		<div id="location">用户组管理</div>
		<div id="funbut">
			<SCRIPT>document.write(mwritetodocument());</SCRIPT>
			</div>
		</td>
        <td class="main_tab1_td1"><img src="<%=path %>/images/img_ht_wz_32.gif" alt="right" /></td>
    </tr>
    <tr>
        <td colspan="3" class="main_tab1_td3">
		<div id="mainbg">
		<div class="jiange10"></div>
        <table width="100%" border="1" cellspacing="0" cellpadding="0" class="main_tab3">
            <tr>
             <th width="100" >
            <img src="<%=path %>/images/img_ht_wz_58.gif" alt="查询条件" class="img_01">查询条件
            </th>
                <td align="left">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main_tab4">
                     	<tr >
                     	<td width="15%" align="right">
                     	用户组名：
                     	</td>
                         <td width="85%" align="left">
                             <input  id="yhzm" name="appsysYhz.yhzm" class="tf1" size="20" maxlength="25" value="<s:property value="appsysYhz.yhzm" />">
                            <s:hidden name="actionId"></s:hidden>
                			<input name="yhzbhs" type="hidden" />
                          </td>
                        </tr>
                </table>
                </td>
            </tr>
        </table>
		<div class="jiange10"></div>
		<div id="divgyDbxxbList" style="height:77%;width:100%; overflow: auto;">
		<table width="100%" id="listTable" border="0" cellspacing="0" cellpadding="0">
		  <thead>
			<tr valign="bottom" align="center">
				<th>全选<input type="checkbox" name="checkbox3" value="1" onclick="selectAll();"></th>
				<th>
					操作
				</th>
				<th>
					用户组名
				</th>
				<th>
					创建人
				</th>
				<th>权限管理</th>
			</tr>
		</thead>
		<tbody>
			<s:iterator  value="yhzList" status="index">
	             <tr valign="bottom" ondblclick="popPage('infoYhz.do?yhzbh=<s:property  value="yhzbh" />',300,450);">
					<td align="center"  class="text_al_1">
						<input type="checkBox" name="yhzbh" onclick="selectNoAll()" value="<s:property  value="yhzbh" />">
						<input type="hidden" name="yhzms" value="<s:property  value="yhzm" />">
					</td>
					<td>
						<a href="#" onclick="doEdit('<s:property  value="yhzbh" />')">修改</a>
						<a href="#" onclick="doDelete('<s:property  value="yhzbh" />')">删除</a>
						<a href="#" onclick="popPage('selYh.do?yhzbhs=<s:property  value="yhzbh" />',820,460)" >所属用户</a>
					</td>
					<td align="left" >
						<a href="#" onclick="popPage('infoYhz.do?yhzbh=<s:property  value="yhzbh" />',400,450);">
							<s:if test="yhzm.length()>10">
								<s:property  value="yhzm.substring(0,10)" />...
							</s:if>
							<s:else>
								<s:property  value="yhzm" />
							</s:else>
						 </a>
					</td>
					<td align="left">&nbsp;<s:property  value="cjr" /></td>
					<td align="center" >
					<a href="#" onclick="doRight('createXmlTree.do?yhzbh=<s:property  value="yhzbh" />')">系统权限</a>
					<!--<a href="#" onclick="doRight('<%=path %>/yhz/rightIndex.jsp?yhzbh=<s:property  value="yhzbh" />')" >功能权限</a>-->
					</td>
				</tr>
			</s:iterator>
		   </tbody>	
			</table>
		</div>
			<jsp:include page="../common/page.jsp">
			      <jsp:param value="yhzList.do" name="doAction"/>
			</jsp:include>
		</div></td>
    </tr>
    <tr>
        <td class="main_tab1_td4"><img src="<%=path %>/images/img_ht_wz_65.gif" alt="left" /></td>
        <td class="main_tab1_td5"></td>
        <td class="main_tab1_td4"><img src="<%=path %>/images/img_ht_wz_67.gif" alt="right" /></td>
    </tr>
    
</table>
</s:form>
</body>
</html>
